#include <bits/stdc++.h>
using namespace std;
const int c=2005;
int n, ans[c];
int kerd(int a) {
cout.flush() << "? " << a << "\n";
char c;
cin >> c;
if (c=='<') return -1;
if (c=='=') return 0;
if (c=='>') return 1;
}
void calc(vector<int> sz, int l, int r) {
int si=sz.size();
if (si==0) {
return;
}
int pos=rand()%si;
while (kerd(sz[pos])) {
}
vector<int> kis, nagy;
for (int i=0; i<si; i++) {
if (i!=pos) {
if (kerd(sz[i])==1) {
nagy.push_back(sz[i]);
} else {
kis.push_back(sz[i]);
}
kerd(sz[pos]);
}
}
int koz=l+kis.size();
ans[sz[pos]]=koz;
calc(kis, l, koz-1), calc(nagy, koz+1, r);
}
void solve() {
cin >> n;
vector<int> sz;
for (int i=1; i<=n; i++) {
sz.push_back(i);
}
calc(sz, 1, n);
cout << "! ";
for (int i=1; i<=n; i++) {
cout << ans[i] << " ";
}
cout.flush() << endl;
}
int main()
{
srand(time(0));
ios_base::sync_with_stdio(false);
int w;
cin >> w;
while (w--) {
solve();
}
return 0;
}
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |